package com.culturaltourism.admin.service.impl;

import com.culturaltourism.admin.mapper.SysUserMapper;
import com.culturaltourism.admin.pojo.SysUser;
import com.culturaltourism.admin.pojo.SysUserExample;
import com.culturaltourism.admin.service.SysUserService;
import com.culturaltourism.core.dto.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: SysUserServiceImpl
 * @Description:
 * @Author MaShuai
 * @Date 2019/5/1 20:02
 * @Version V1.0
 */
@Service("SysUserService")
public class SysUserServiceImpl implements SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public Result getSysUser(Long id) {
        return null;
    }

    @Override
    public Result getSysUserList(Integer page, Integer limit) {
        if(page != null && limit != null){
            PageHelper.startPage(page, limit);
            SysUserExample sysUserExample = new SysUserExample();
            List<SysUser> list = sysUserMapper.selectByExample(sysUserExample);
            PageInfo<SysUser> pageInfo = new PageInfo<>(list);
            return Result.success(pageInfo.getList());
        } else {
            return Result.error("分页查询用户失败！");
        }
    }

    @Override
    public Result updateSysUser(SysUser sysUser) {
        return null;
    }
}
